package com.stone.action;

import java.util.Map;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.stone.model.Admin;
import com.stone.model.StaticHTML;
import com.stone.service.ILoggerService;
import com.stone.service.IStaticHTMLService;
import com.stone.serviceimpl.LoggerService;
import com.stone.utils.LogConstrants;

public class StaticHTMLAction extends ActionSupport {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1830588704352735782L;
	
	private IStaticHTMLService staticHTMLService;
	private ILoggerService logService = new LoggerService();
	
	private StaticHTML staticHTML;
	
	private static Logger logger = Logger.getLogger("系统静态页面");
	//------------------
	
	public String toUpdateAboutUs(){
		staticHTML = staticHTMLService.findAboutUs();
		return SUCCESS;
	}
	
	/**
	 * 返回石材加工厂
	 * @return
	 */
	public String toUpdateStoneProcessor(){
		staticHTML = staticHTMLService.findStoneProcessor();
		return SUCCESS;
	}
	
	/**
	 * 物流公司
	 * @return
	 */
	public String toUpdatePhysicalDistribution(){
		staticHTML = staticHTMLService.findPhysicalDistribution();
		return SUCCESS;
	}
	
	/**
	 * 酒店
	 * @return
	 */
	public String toUpdateHotel(){
		staticHTML = staticHTMLService.findHotel();
		return SUCCESS;
	}
	
	/**
	 * 客户
	 * @return
	 */
	public String toUpdateClient(){
		staticHTML = staticHTMLService.findClient();
		return SUCCESS;
	}
	
	
	/**
	 * 更新
	 * @return
	 */
	public String update(){
		staticHTMLService.updateStaticHTML(staticHTML);
		Map<String, Object> session = ActionContext.getContext().getSession();
		logger.fatal(((Admin)session.get("admin")).getUsername()+"更新了页面 ("+staticHTML.getType() +"); 1-->关于我们,2-->石材加工厂,3-->物流公司,4-->酒店,5-->客户");
		logService.log(((Admin)session.get("admin")).getUsername(), "更新了页面 ("+staticHTML.getType() +"); 1-->关于我们,2-->石材加工厂,3-->物流公司,4-->酒店,5-->客户", LogConstrants.STATIC_HTML_UPDATE);
		return SUCCESS;
	}
	
	
	//------------------ SET AND GET
	public IStaticHTMLService getStaticHTMLService() {
		return staticHTMLService;
	}

	public void setStaticHTMLService(IStaticHTMLService staticHTMLService) {
		this.staticHTMLService = staticHTMLService;
	}

	public StaticHTML getStaticHTML() {
		return staticHTML;
	}

	public void setStaticHTML(StaticHTML staticHTML) {
		this.staticHTML = staticHTML;
	}
	
}
